<template>
  <!--基本信息  -->
  <FormPanel ref="FormPanel" :list="initForm" :cols="2" :formType="formType" :labelWidth="160" :isSubmitBtn="false" @formChange="formChangeHandle" class="mtop" />
</template>

<script>
import { getAppId } from '@/assets/js/auth'; //获取登录用户

import { region } from '@/api/cms-common/region'; //行政区域
import { getRegion, getCommunity } from '@/api/cms-common/dealerdata/index'; //事业部，办事处

import { dictionary } from '@/utils/dictMixin';
import * as types from '@/api/cms-api/origin/originInfo/types';
import * as constructTypes from '@/api/cms-api/origin/construct/dealer/types';

import { dealerCommon, isArcfox } from '@/api/cms-api/origin/commonDealerType'; //经销商类型工具类

import vm from './bridge';

export default {
  mixins: [dictionary, region, dealerCommon],
  model: {
    prop: 'pdata',
    event: 'click'
  },
  props: {
    pdata: {
      type: Object,
      default: () => ({ auditStatus: -1 })
    },
    formType: {
      type: String,
      required: true
    },
    formOptions: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      opneKey: 1
    };
  },
  mounted() {
    //初始化省份
    this.initProvince();
    this.getDeptData();

    //注册经销商类型变化时触发的事件
    //在审核时，给此页面的类型为只读，但是基本信息（infoBase可以编辑，会显示会触发事件，事件会触发禁用取消，覆盖整个表单的类型（表单类型为show，但是依旧可以输入，（部分）））
    if (this.formType != 'show') {
      vm.$on('changeDealerType', this.changeDealerType);
      this.changeDealerTypeToDep(types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER);
    }
  },
  methods: {
    //初始化数据
    init() {
      //经销商类型
      if (this.formType != 'show') {
        if (this.formType == 'edit') {
          //如果是edit并且是空数据，则恢复填写状态
          if (!this.pdata.dealerType) {
            // this.initForm.fin的(x => x.fieldName === 'dealerType').disabled = false;
          }
        } else if (this.formType == 'add') {
          //触发事件
          vm.$emit('changeDealerType', types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER);
          this.changeDealerTypeToDep(types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER);
        }
        if (this.pdata.dealerType) {
          //触发事件
          vm.$emit('changeDealerType', this.pdata.dealerType);
          this.changeDealerTypeToDep(this.pdata.dealerType, false);
        }
      }
      this.initForm.forEach(x => {
        //回显下拉选需要的ID
        if (x.fieldName === 'dealerType') {
        } else if (x.fieldName === 'ownBrand') {
          //体系内品牌（后台存的是字符串，用‘,’拼接的，回显得转成数字的数组）
          if (this.pdata[x.fieldName]) {
            let list = this.pdata[x.fieldName].split(',');
            this.pdata[x.fieldName] = list.map(x => parseInt(x));
          } else {
            //默认值
            this.pdata[x.fieldName] = [];
          }
        }
        //回显数据
        if (this.pdata[x.fieldName]) {
          x.initialValue = this.pdata[x.fieldName];
        }
      });
      //添加级联下拉选（初始化市，区）
      this.initRegion(this.pdata.provinceId, this.pdata.cityId);
      //初始化办事处
      this.changeDeptSelect(this.pdata.deptId, false);
    },

    //获取事业部下拉列表数据
    async getDeptData() {
      const res = await getRegion();
      if (res.resultCode === 200) {
        this.initForm.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      }
    },
    //表单验证通过后
    formChangeHandle(val) {
      this.pdata = Object.assign(this.pdata, val);
      this.pdata.ownBrand = this.pdata.ownBrand.join(',');
      //传递数据到父组件里
      this.$emit('click', this.pdata);
      //触发外部的事件，以标志着本表单已经准备完毕
      this.$emit('formchange', this.pdata);
    },
    //开放的提交方法
    saveDialog() {
      let err = this.$refs.FormPanel.SUBMIT_FORM();
      this.$refs.FormPanel.$refs.form.validate().then(res => {
        //console.log(res)
      });
    },
    //经销商类型变更时
    changeDealerType(value) {
      //根据类型处理验证
      if (types.DEALER_INFO_DEALER_TYPE_4S === value) {
        //4S
        // vm.changeForm(this.initForm, '4S', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_SINGLE_AFTER_SALE === value) {
        //单一售后
        // vm.changeForm(this.initForm, 'SH', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_SINGLE_SALE === value) {
        //单一销售
        // vm.changeForm(this.initForm, 'XS', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_DIRECT_SHOP === value) {
        //SPACE
        // vm.changeForm(this.initForm, 'SPACE', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_NO_DIRECT_SHOP === value) {
        //RACE
        // vm.changeForm(this.initForm, 'RACE', false);
        vm.clearValidate(this.$refs.FormPanel);
      } else if (types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER === value) {
        //大客户
        // vm.changeForm(this.initForm, 'DKH', false);
        vm.clearValidate(this.$refs.FormPanel);
      }
      //另做处理，不是简单的起用禁用(显示，不显示)
      //维修资质： 4S和单一售后必填，单一销售和SPACE RACE时灰色不填
      //SPACE和RACE的经销商级别、展厅级别、售后级别及其他售后专用字段不显示
      //SPACE，RACE
      // if(types.DEALER_INFO_DEALER_TYPE_DIRECT_SHOP === value || types.DEALER_INFO_DEALER_TYPE_NO_DIRECT_SHOP === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = true;
      // //4S店
      // }else if(types.DEALER_INFO_DEALER_TYPE_4S === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // //单一销售
      // }else if(types.DEALER_INFO_DEALER_TYPE_SINGLE_SALE === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // //单一售后
      // }else if(types.DEALER_INFO_DEALER_TYPE_SINGLE_AFTER_SALE === value){
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // }else{
      // 	//经销商级别
      // 	this.initForm.find(x => x.fieldName === 'shopLevel').hidden = false;
      // }
    },
    //根据大客户类型变更事业部
    changeDealerTypeToDep(value, isChear = true) {
      //变更其事业部(包不好含大客户专属的机构)
      if (isChear) {
        this.initForm.find(item => item.fieldName === 'deptId').initialValue = '';
      }
      if (types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER === value) {
        this.getBigcustomerData();
      } else {
        this.getNotBigcustomerData();
      }
    },
    //根据不同的状态展现不同的选项（如果直接在经销商信息维护里添加只能选择大客户）
    createDealerTypeByType() {
      if (this.formOptions.formType === types.DEALER_INFO_FORM_STATUS_MAINTAIN_OEM) {
        //只能选择大客户
        return this.getOriginInfoDealerTypeToNotDisabled();
        //return this.createDictList(2538)
      } else {
        return this.getOriginInfoDealerType();
      }
    },
    //初始化市，区
    initRegion(provinceId, cityId) {
      this.initCity(provinceId, false);
      this.initTown(cityId, false);
    },
    //初始化所在省份
    async initProvince() {
      let pl = await this.createRegionList();
      this.initForm.find(item => item.fieldName === 'provinceId').itemList = pl;
    },
    //初始化所在市数据
    async initCity(provinceId, flag = true) {
      if (!provinceId || provinceId == null || typeof provinceId == 'undefined') {
        return;
      }
      let city = this.initForm.find(item => item.fieldName === 'cityId');
      //清空下级数据
      if (flag) {
        city.initialValue = '';
        let district = this.initForm.find(item => item.fieldName === 'districtId');
        district.initialValue = '';
        district.itemList = [];
      }
      //取省数据
      let rd = this.getRegionData();
      this.cityData = rd[provinceId].children;
      let cl = this.createSubRegionList(this.cityData);
      city.itemList = cl;
    },
    //初始化所在县市数据
    async initTown(cityId, flag = true) {
      if (!cityId || cityId == null || typeof cityId == 'undefined') {
        return;
      }
      let district = this.initForm.find(item => item.fieldName === 'districtId');
      //清空下级数据
      if (flag) {
        district.initialValue = '';
      }
      let td = this.cityData[cityId].children;
      let tl = this.createSubRegionList(td);
      //部分城市为县级市，没有县区的下级数据
      if (tl.length == 0) {
        district.rules.required = false;
        district.itemList = [];
        this.$refs.FormPanel.$refs.form.clearValidate();
      } else {
        district.rules.required = true;
        district.itemList = tl;
      }
    },
    //获取事业部下拉列表数据(只有‘大客户事业部’)
    async getBigcustomerData() {
      const dictList = await this._$getBigcustomerData();
      //if (res.resultCode === 200) {
      //this.initForm.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      //}
      this.initForm.find(item => item.fieldName === 'deptId').itemList = dictList;
    },
    //获取事业部下拉列表数据(不包含‘大客户事业部’)
    async getNotBigcustomerData() {
      const dictList = await this._$getNotBigcustomerData();
      //if (res.resultCode === 200) {
      //this.initForm.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      //}
      this.initForm.find(item => item.fieldName === 'deptId').itemList = dictList;
    },
    //事业部下拉改变执行方法，级联查询该事业部下的办事处
    async changeDeptSelect(deptId, flag = true) {
      let initForm$officeId = this.initForm.find(item => item.fieldName === 'officeId');
      if (!deptId) {
        initForm$officeId.initialValue = '';
        initForm$officeId.itemList = [];
      } else {
        if (flag) {
          //正常的级联，清空原来选择的数据
          initForm$officeId.initialValue = '';
        }
        const res = await getCommunity(deptId);
        if (res.resultCode === 200) {
          initForm$officeId.itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
        }
      }
    },
    //表单数据
    initFormFun() {
      let isNotAdd = this.formType != 'add';
      let bt = { required: true, message: '必填', trigger: ['change', 'blur'] };
      let districtChangeBt = { required: true, message: '必填', trigger: ['change', 'blur'] };
      let btl = [bt];
      let sj = { pattern: /^1[2-9]\d{9}$/, message: '请填写正确的手机号', trigger: ['change', 'blur'] };
      let yc = { hidden: true };
      if (isArcfox()) {
        //arcfox编辑页面
        return [
          { type: 'INPUT', label: '品牌', fieldName: 'appIdUpper', disabled: true, initialValue: getAppId().toLocaleUpperCase(), placeholder: '', noChangeDisabled: true, noWipeData: true },
          // { type: 'INPUT', label: '品牌', fieldName: 'appId', disabled: true, initialValue: getAppId(),placeholder:'',noChangeDisabled:true,noWipeData:true},
          {
            type: 'INPUT',
            label: '经销商简称',
            fieldName: 'dealerShortname',
            placeholder: '请输入',
            disabled: true,
            initialValue: '',
            maxlength: isArcfox() ? 15 : 8
            // rules: btl,
            // rules4S: btl, //4S
            // rulesSH: btl, //单一售后
            // rulesXS: btl, //单一销售
            // rulesSPACE: btl, //SPACE
            // rulesRACE: btl, //RACE
            // rulesDKH: btl //大客户
          },
          { type: 'INPUT', label: '经销商代码', fieldName: 'dealerCode', disabled: true, initialValue: '', placeholder: '自动生成', noChangeDisabled: true, noWipeData: true },
          {
            type: 'INPUT',
            label: '公司全称',
            fieldName: 'dealerName',
            selfCols: 2,
            rows: 1,
            initialValue: '',
            placeholder: '请输入',
            maxlength: 300,
            rules: btl,
            rules4S: btl,
            rulesSH: btl,
            rulesXS: btl,
            rulesSPACE: btl,
            rulesRACE: btl,
            rulesDKH: btl,
            change: val => {
              //顺便填写到简称里
              this.$nextTick(() => {
                this.$parent.$refs.infoCompany.initForm.find(x => x.fieldName === 'companyName').initialValue = val;
              });
            }
          },
          {
            type: 'SELECT',
            label: '销售模式',
            fieldName: 'saleType',
            placeholder: '请选择',
            itemList: this.createDictList('6501'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '渠道类型',
            fieldName: 'dealerType',
            placeholder: '请选择',
            initialValue: !isNotAdd ? types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER : '',
            itemList: this.createDealerTypeByType(),
            noChangeDisabled: true,
            noWipeData: true,
            disabled: isNotAdd,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl,
            change(value) {
              //调用其兄弟节点的方法，
              vm.$emit('changeDealerType', value);
            }
          },
          {
            type: 'SELECT',
            label: '开票资质',
            fieldName: 'billType',
            placeholder: '请选择',
            initialValue: !isNotAdd ? types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER : '',
            itemList: this.createDictList('1004'),
            noChangeDisabled: true,
            noWipeData: true,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '店面等级',
            fieldName: 'constructLevel',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('2554'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },

          {
            type: 'SELECT',
            label: '经销商级别',
            fieldName: 'shopLevel',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('2540'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: yc,
            // rulesRACE: yc,
            // rulesDKH: btl
          },
          // { type: 'SELECT', label: '细分类别', fieldName: 'subType', placeholder: '请选择', initialValue: '', itemList: this.createDictList('2539'),
          //如果是arcfox则细分类别必填,并显示，如果不是则不必填并隐藏
          // hidden: !isArcfox(),
          // rules: isArcfox() ?[{required: true,message: '必填',trigger: 'change'}]:[]
          // },
          {
            type: 'SELECT',
            label: '建设类型',
            disabled: true,
            fieldName: 'constructType',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('2541'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: []
          },

          {
            type: 'SELECT',
            label: '事业部',
            fieldName: 'deptId',
            placeholder: '请选择',
            initialValue: '',
            itemList: [],
            change: val => {
              this.changeDeptSelect(val);
            },
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '办事处',
            fieldName: 'officeId',
            placeholder: '请选择',
            initialValue: '',
            itemList: [],
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '启用标记',
            fieldName: 'status',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('1003'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '省份',
            fieldName: 'provinceId',
            placeholder: '请选择',
            initialValue: '',
            itemList: [],
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl,
            change: props => {
              this.initCity(props);
            }
          },
          {
            type: 'SELECT',
            label: '城市',
            fieldName: 'cityId',
            placeholder: '请选择',
            initialValue: '',
            itemList: [],
            change: props => this.initTown(props),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          { type: 'SELECT', label: '县区', fieldName: 'districtId', placeholder: '请选择', initialValue: '', itemList: []}, //rules: districtChangeBt },
          {
            type: 'SELECT',
            label: '经营状态',
            fieldName: 'dealerStatus',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('2552'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '是否启用中央补贴',
            fieldName: 'isCentrelAllowance',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('1004'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '是否启用地方补贴',
            fieldName: 'isRegionalAllowance',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('1004'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'INPUT',
            label: '系统管理员',
            fieldName: 'systemManager',
            placeholder: '请输入',
            initialValue: '',
            maxlength: 90,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'INPUT',
            label: '管理员电话',
            fieldName: 'sysManagerPhone',
            initialValue: '',
            maxlength: 20,
            // rules: [bt, sj], //默认
            // rules4S: [bt, sj], //4S店
            // rulesSH: [bt, sj], //单一售后
            // rulesXS: [bt, sj], //单一销售
            // rulesSPACE: [bt, sj], //SPACE
            // rulesRACE: [bt, sj], //RACE
            // rulesDKH: [bt, sj] //大客户
          },
          {
            type: 'SELECT',
            label: '开票是否包含地方补贴',
            fieldName: 'isContainRAllowance',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('1004'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'INPUT_NUMBER',
            label: '保证金金额',
            fieldName: 'cashDeposit',
            initialValue: undefined,
            precision: 2,
            min: 0,
            max: 999999999999999.99,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          { type: 'MULTIPLE_SELECT', label: '体系内品牌', fieldName: 'ownBrand', placeholder: '请选择', initialValue: [], itemList: this.createDictList('2545') },
          {
            type: 'INPUT_NUMBER',
            label: '设计费金额',
            fieldName: 'designFee',
            initialValue: undefined,
            precision: 2,
            min: 0,
            max: 999999999999999.99,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: []
          },
          {
            type: 'SELECT',
            label: '建店标准',
            fieldName: 'constructStandard',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('2553'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: []
          },
          { type: 'INPUT_NUMBER', label: '补贴金额', fieldName: 'allowanceFee', initialValue: undefined, precision: 2, min: 0, max: 999999999999999.99 },
          { type: 'TEXT_AREA', label: '其他', rows: 2, selfCols: 2, maxlength: 1000, fieldName: 'otherDesc', initialValue: '' },
          {
            type: 'UPLOAD_FILE',
            label: '设计费附件',
            fieldName: 'designFeeEnclosureList',
            initialValue: [],
            upload: {
              actionUrl: '/api/file/oss/upload', //上传的地址
              limit: 99, //上传数量
              min: 1,
              max: 10240, //kb
              fileTypes: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'rar', 'zip']
            }
          },
          {
            type: 'UPLOAD_FILE',
            label: '保证金附件',
            fieldName: 'cashDepositEnclosureList',
            initialValue: [],
            upload: {
              actionUrl: '/api/file/oss/upload', //上传的地址
              limit: 99, //上传数量
              min: 1,
              max: 10240, //kb
              fileTypes: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'rar', 'zip']
            }
          }
        ];
      } else {
        //北京
        return [
          { type: 'INPUT', label: '品牌', fieldName: 'appIdUpper', disabled: true, initialValue: getAppId().toLocaleUpperCase(), placeholder: '', noChangeDisabled: true, noWipeData: true },
          // { type: 'INPUT', label: '品牌', fieldName: 'appId', disabled: true, initialValue: getAppId(),placeholder:'',noChangeDisabled:true,noWipeData:true},
          {
            type: 'INPUT',
            label: '经销商简称',
            fieldName: 'dealerShortname',
            placeholder: '请输入',
            initialValue: '',
            disabled: true,
            maxlength: isArcfox() ? 15 : 8,
            // rules: btl,
            // rules4S: btl, //4S
            // rulesSH: btl, //单一售后
            // rulesXS: btl, //单一销售
            // rulesSPACE: btl, //SPACE
            // rulesRACE: btl, //RACE
            // rulesDKH: btl //大客户
          },
          { type: 'INPUT', label: '经销商代码', fieldName: 'dealerCode', disabled: true, initialValue: '', placeholder: '自动生成', noChangeDisabled: true, noWipeData: true },
          {
            type: 'INPUT',
            label: '公司全称',
            fieldName: 'dealerName',
            selfCols: 2,
            rows: 1,
            initialValue: '',
            placeholder: '请输入',
            maxlength: 300,
            rules: btl,
            rules4S: btl,
            rulesSH: btl,
            rulesXS: btl,
            rulesSPACE: btl,
            rulesRACE: btl,
            rulesDKH: btl,
            change: val => {
              //顺便填写到简称里
              this.$nextTick(() => {
                this.$parent.$refs.infoCompany.initForm.find(x => x.fieldName === 'companyName').initialValue = val;
              });
            }
          },
          {
            type: 'SELECT',
            label: '经销商级别',
            fieldName: 'shopLevel',
            placeholder: '请选择',
            initialValue: '',
            disabled: true,
            itemList: this.createDictList('2540'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: yc,
            // rulesRACE: yc,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '渠道类型',
            fieldName: 'dealerType',
            placeholder: '请选择',
            initialValue: !isNotAdd ? types.DEALER_INFO_DEALER_TYPE_BIG_CUSTOMER : '',
            itemList: this.createDealerTypeByType(),
            noChangeDisabled: true,
            noWipeData: true,
            disabled: isNotAdd,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl,
            change(value) {
              //调用其兄弟节点的方法，
              vm.$emit('changeDealerType', value);
            }
          },
          // { type: 'SELECT', label: '细分类别', fieldName: 'subType', placeholder: '请选择', initialValue: '', itemList: this.createDictList('2539'),
          //如果是arcfox则细分类别必填,并显示，如果不是则不必填并隐藏
          // hidden: !isArcfox(),
          // rules: isArcfox() ?[{required: true,message: '必填',trigger: 'change'}]:[]
          // },
          {
            type: 'SELECT',
            label: '建设类型',
            disabled: true,
            fieldName: 'constructType',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('2541'),
            // rules: btl,
            // disabled: true,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: []
          },

          {
            type: 'SELECT',
            label: '事业部',
            fieldName: 'deptId',
            placeholder: '请选择',
            initialValue: '',
            disabled: true,
            itemList: [],
            change: val => {
              this.changeDeptSelect(val);
            },
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '办事处',
            fieldName: 'officeId',
            disabled: true,
            placeholder: '请选择',
            initialValue: '',
            itemList: [],
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '启用标记',
            fieldName: 'status',
            disabled: true,
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('1003'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '省份',
            fieldName: 'provinceId',
            placeholder: '请选择',
            initialValue: '',
            disabled: true,
            itemList: [],
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl,
            change: props => {
              this.initCity(props);
            }
          },
          {
            type: 'SELECT',
            label: '城市',
            fieldName: 'cityId',
            placeholder: '请选择',
            initialValue: '',
            disabled: true,
            itemList: [],
            change: props => this.initTown(props),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          { type: 'SELECT',disabled: true, label: '县区', fieldName: 'districtId', placeholder: '请选择', initialValue: '', itemList: []}, //rules: districtChangeBt },
          {
            type: 'SELECT',
            label: '经营状态',
            fieldName: 'dealerStatus',
            placeholder: '请选择',
            disabled: true,
            initialValue: '',
            itemList: this.createDictList('2552'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '是否启用中央补贴',
            fieldName: 'isCentrelAllowance',
            disabled: true,
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('1004'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'SELECT',
            label: '是否启用地方补贴',
            fieldName: 'isRegionalAllowance',
            placeholder: '请选择',
            initialValue: '',
            disabled: true,
            itemList: this.createDictList('1004'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'INPUT',
            label: '系统管理员',
            fieldName: 'systemManager',
            placeholder: '请输入',
            initialValue: '',
            maxlength: 90,
            disabled: true,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'INPUT',
            label: '管理员电话',
            fieldName: 'sysManagerPhone',
            initialValue: '',
            disabled: true,
            maxlength: 20,
            // rules: [bt, sj], //默认
            // rules4S: [bt, sj], //4S店
            // rulesSH: [bt, sj], //单一售后
            // rulesXS: [bt, sj], //单一销售
            // rulesSPACE: [bt, sj], //SPACE
            // rulesRACE: [bt, sj], //RACE
            // rulesDKH: [bt, sj] //大客户
          },
          {
            type: 'SELECT',
            label: '开票是否包含地方补贴',
            fieldName: 'isContainRAllowance',
            placeholder: '请选择',
            initialValue: '',
            itemList: this.createDictList('1004'),
            // rules: btl,
            // disabled: true,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          {
            type: 'INPUT_NUMBER',
            label: '保证金金额',
            fieldName: 'cashDeposit',
            initialValue: undefined,
            precision: 2,
            disabled: true,
            min: 0,
            max: 999999999999999.99,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: btl
          },
          { type: 'MULTIPLE_SELECT',disabled: true, label: '体系内品牌', fieldName: 'ownBrand', placeholder: '请选择', initialValue: [], itemList: this.createDictList('2545') },
          {
            type: 'INPUT_NUMBER',
            label: '设计费金额',
            fieldName: 'designFee',
            disabled: true,
            initialValue: undefined,
            precision: 2,
            min: 0,
            max: 999999999999999.99,
            // rules: btl,
            // rules4S: btl,
            // rulesSH: [],
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: []
          },
          {
            type: 'SELECT',
            label: '建店标准',
            fieldName: 'constructStandard',
            placeholder: '请选择',
            disabled: true,
            initialValue: '',
            itemList: this.createDictList('2553'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: []
          },
          { type: 'INPUT_NUMBER', label: '补贴金额',disabled: true, fieldName: 'allowanceFee', initialValue: undefined, precision: 2, min: 0, max: 999999999999999.99 },
          {
            type: 'SELECT',
            label: '店面等级',
            fieldName: 'constructLevel',
            placeholder: '请选择',
            disabled: true,
            initialValue: '',
            itemList: this.createDictList('2554'),
            // rules: btl,
            // rules4S: btl,
            // rulesSH: btl,
            // rulesXS: btl,
            // rulesSPACE: btl,
            // rulesRACE: btl,
            // rulesDKH: []
          },
          { type: 'TEXT_AREA', label: '其他',disabled: true, rows: 2, selfCols: 2, maxlength: 1000, fieldName: 'otherDesc', initialValue: '' },
          {
            type: 'UPLOAD_FILE',
            label: '设计费附件',
            disabled: true,
            fieldName: 'designFeeEnclosureList',
            initialValue: [],
            upload: {
              actionUrl: '/api/file/oss/upload', //上传的地址
              limit: 99, //上传数量
              min: 1,
              max: 10240, //kb
              fileTypes: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'rar', 'zip']
            }
          },
          {
            type: 'UPLOAD_FILE',
            label: '保证金附件',
            disabled: true,
            fieldName: 'cashDepositEnclosureList',
            initialValue: [],
            upload: {
              actionUrl: '/api/file/oss/upload', //上传的地址
              limit: 99, //上传数量
              min: 1,
              max: 10240, //kb
              fileTypes: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'rar', 'zip']
            }
          }
        ];
      }
    }
  }
};
</script>
